/* Copyright (C) 2016 RDA Technologies Limited and/or its affiliates("RDA").
* All rights reserved.
*
* This software is supplied "AS IS" without any warranties.
* RDA assumes no responsibility or liability for the use of the software,
* conveys no license or title under any patent, copyright, or mask work
* right to the product. RDA reserves the right to make changes in the
* software without notification.  RDA also make no representation or
* warranty that such application will be suitable for the specified use
* without further testing or modification.
*/


#ifndef _ABB_H_
#define _ABB_H_

#ifdef CT_ASM
#error "You are trying to use in an assembly code the normal H description of 'abb'."
#endif


#include "globals.h"

// =============================================================================
//  MACROS
// =============================================================================

// =============================================================================
//  TYPES
// =============================================================================

// ============================================================================
// ABB_T
// -----------------------------------------------------------------------------
///
// =============================================================================
#define REG_ABB_BASE               0xA2000500

typedef volatile struct
{
    REG16                          CHIP_ID;                      //0x00000000
    REG16                          GPADC_settings1;              //0x00000002
    REG16                          CODEC_settings1;              //0x00000004
    REG16                          CODEC_settings2;              //0x00000006
    REG16                          USB_control;                  //0x00000008
    REG16                          GPADC_settings2;              //0x0000000A
    REG16                          PLL_settings1;                //0x0000000C
    REG16                          PLL_settings2;                //0x0000000E
    REG16                          FM_DAC_settings;              //0x00000010
    REG16                          CODEC_LDO_settings_1;         //0x00000012
    REG16                          CODEC_LDO_settings_2;         //0x00000014
    REG16                          MISC_settings;                //0x00000016
    REG16                          CODEC_mode_sel;               //0x00000018
    REG16                          CODEC_calib_settings;         //0x0000001A
    REG16                          Power_control;                //0x0000001C
    REG16                          CODEC_reset_control;          //0x0000001E
} HWP_ABB_T;

#define hwp_abb                    ((HWP_ABB_T*) KSEG1(REG_ABB_BASE))


//CHIP_ID
#define ABB_REVISION_ID(n)         (((n)&15)<<0)
#define ABB_REVISION_ID_MASK       (15<<0)
#define ABB_REVISION_ID_SHIFT      (0)
#define ABB_CHIP_ID_FIELD(n)       (((n)&0xFFF)<<4)
#define ABB_CHIP_ID_FIELD_MASK     (0xFFF<<4)
#define ABB_CHIP_ID_FIELD_SHIFT    (4)

//GPADC_settings1
#define ABB_SOFT_RESETN            (1<<0)
#define ABB_SOFT_RESETN_MASK       (1<<0)
#define ABB_SOFT_RESETN_SHIFT      (0)
#define ABB_SOFT_RESETN_RESET      (0<<0)
#define ABB_SOFT_RESETN_NO_RESET   (1<<0)
#define ABB_REGISTER_RESETN        (1<<1)
#define ABB_REGISTER_RESETN_MASK   (1<<1)
#define ABB_REGISTER_RESETN_SHIFT  (1)
#define ABB_REGISTER_RESETN_RESET  (0<<1)
#define ABB_REGISTER_RESETN_NO_RESET (1<<1)
#define ABB_GPADC_IN(n)            (((n)&0x3FF)<<2)
#define ABB_GPADC_IN_MASK          (0x3FF<<2)
#define ABB_GPADC_IN_SHIFT         (2)
#define ABB_GPADC_EOC              (1<<12)
#define ABB_GPADC_EOC_MASK         (1<<12)
#define ABB_GPADC_EOC_SHIFT        (12)
#define ABB_FBC_STATE              (1<<13)
#define ABB_FBC_STATE_MASK         (1<<13)
#define ABB_FBC_STATE_SHIFT        (13)
#define ABB_ISPHONE_CODEC          (1<<14)
#define ABB_ISPHONE_CODEC_MASK     (1<<14)
#define ABB_ISPHONE_CODEC_SHIFT    (14)
#define ABB_CODEC_EN_CODEC         (1<<15)
#define ABB_CODEC_EN_CODEC_MASK    (1<<15)
#define ABB_CODEC_EN_CODEC_SHIFT   (15)

//CODEC_settings1
#define ABB_AU_HEAD_SEL_REG        (1<<0)
#define ABB_AU_HEAD_SEL_REG_MASK   (1<<0)
#define ABB_AU_HEAD_SEL_REG_SHIFT  (0)
#define ABB_AU_HEAD_SEL_REG_DEFAULT (0<<0)
#define ABB_AU_HEAD_SEL_REG_SELECT_HEADPHONE_PA (1<<0)
#define ABB_AU_RCV_SEL_REG         (1<<1)
#define ABB_AU_RCV_SEL_REG_MASK    (1<<1)
#define ABB_AU_RCV_SEL_REG_SHIFT   (1)
#define ABB_AU_RCV_SEL_REG_DEFAULT (0<<1)
#define ABB_AU_RCV_SEL_REG_SELECT_RECEIVER_PA (1<<1)
#define ABB_AU_SPK_SEL_REG         (1<<2)
#define ABB_AU_SPK_SEL_REG_MASK    (1<<2)
#define ABB_AU_SPK_SEL_REG_SHIFT   (2)
#define ABB_AU_SPK_SEL_REG_DEFAULT (0<<2)
#define ABB_AU_SPK_SEL_REG_SELECT_SPEAKER_PA (1<<2)
#define ABB_AU_MIC_MUTE_N_REG      (1<<3)
#define ABB_AU_MIC_MUTE_N_REG_MASK (1<<3)
#define ABB_AU_MIC_MUTE_N_REG_SHIFT (3)
#define ABB_AU_MIC_MUTE_N_REG_MUTE (0<<3)
#define ABB_AU_MIC_MUTE_N_REG_NO_MUTE (1<<3)
#define ABB_AU_MIC_GAIN_REG(n)     (((n)&15)<<4)
#define ABB_AU_MIC_GAIN_REG_MASK   (15<<4)
#define ABB_AU_MIC_GAIN_REG_SHIFT  (4)
#define ABB_AU_AUXMIC_PD_N_REG     (1<<8)
#define ABB_AU_AUXMIC_PD_N_REG_MASK (1<<8)
#define ABB_AU_AUXMIC_PD_N_REG_SHIFT (8)
#define ABB_AU_AUXMIC_PD_N_REG_POWER_DOWN (0<<8)
#define ABB_AU_AUXMIC_PD_N_REG_POWER_UP (1<<8)
#define ABB_AU_AUXMIC_SEL_REG      (1<<9)
#define ABB_AU_AUXMIC_SEL_REG_MASK (1<<9)
#define ABB_AU_AUXMIC_SEL_REG_SHIFT (9)
#define ABB_AU_AUXMIC_SEL_REG_SELECT_MIC (0<<9)
#define ABB_AU_AUXMIC_SEL_REG_SELECT_AUX_MIC (1<<9)
#define ABB_AU_DAC_PD_N_REG        (1<<10)
#define ABB_AU_DAC_PD_N_REG_MASK   (1<<10)
#define ABB_AU_DAC_PD_N_REG_SHIFT  (10)
#define ABB_AU_DAC_PD_N_REG_POWER_DOWN (0<<10)
#define ABB_AU_DAC_PD_N_REG_POWER_UP (1<<10)
#define ABB_AU_ADC_PD_N_REG        (1<<11)
#define ABB_AU_ADC_PD_N_REG_MASK   (1<<11)
#define ABB_AU_ADC_PD_N_REG_SHIFT  (11)
#define ABB_AU_ADC_PD_N_REG_POWER_DOWN (0<<11)
#define ABB_AU_ADC_PD_N_REG_POWER_UP (1<<11)
#define ABB_AU_MIC_PD_N_REG        (1<<12)
#define ABB_AU_MIC_PD_N_REG_MASK   (1<<12)
#define ABB_AU_MIC_PD_N_REG_SHIFT  (12)
#define ABB_AU_MIC_PD_N_REG_POWER_DOWN (0<<12)
#define ABB_AU_MIC_PD_N_REG_POWER_UP (1<<12)
#define ABB_AU_REF_PD_N_REG        (1<<13)
#define ABB_AU_REF_PD_N_REG_MASK   (1<<13)
#define ABB_AU_REF_PD_N_REG_SHIFT  (13)
#define ABB_AU_REF_PD_N_REG_POWER_DOWN (0<<13)
#define ABB_AU_REF_PD_N_REG_POWER_UP (1<<13)
#define ABB_AU_DEEP_PD_N_REG       (1<<14)
#define ABB_AU_DEEP_PD_N_REG_MASK  (1<<14)
#define ABB_AU_DEEP_PD_N_REG_SHIFT (14)
#define ABB_AU_DEEP_PD_N_REG_POWER_DOWN (0<<14)
#define ABB_AU_DEEP_PD_N_REG_POWER_UP (1<<14)
#define ABB_CODEC_CONTROL_BY_ABB   (1<<15)
#define ABB_CODEC_CONTROL_BY_ABB_MASK (1<<15)
#define ABB_CODEC_CONTROL_BY_ABB_SHIFT (15)
#define ABB_CODEC_CONTROL_BY_ABB_FROM_DBB_PIN (0<<15)
#define ABB_CODEC_CONTROL_BY_ABB_THROUGH_SPI (1<<15)

//CODEC_settings2
#define ABB_AU_HEAD_GAIN_REG(n)    (((n)&15)<<0)
#define ABB_AU_HEAD_GAIN_REG_MASK  (15<<0)
#define ABB_AU_HEAD_GAIN_REG_SHIFT (0)
#define ABB_AU_RCV_GAIN_REG(n)     (((n)&15)<<4)
#define ABB_AU_RCV_GAIN_REG_MASK   (15<<4)
#define ABB_AU_RCV_GAIN_REG_SHIFT  (4)
#define ABB_AU_SPK_GAIN_REG(n)     (((n)&15)<<8)
#define ABB_AU_SPK_GAIN_REG_MASK   (15<<8)
#define ABB_AU_SPK_GAIN_REG_SHIFT  (8)
#define ABB_AU_DAC_RESET_N_REG     (1<<12)
#define ABB_AU_DAC_RESET_N_REG_MASK (1<<12)
#define ABB_AU_DAC_RESET_N_REG_SHIFT (12)
#define ABB_AU_DAC_RESET_N_REG_RESET (0<<12)
#define ABB_AU_DAC_RESET_N_REG_NO_RESET (1<<12)
#define ABB_AU_SPK_MUTE_N_REG      (1<<13)
#define ABB_AU_SPK_MUTE_N_REG_MASK (1<<13)
#define ABB_AU_SPK_MUTE_N_REG_SHIFT (13)
#define ABB_AU_SPK_MUTE_N_REG_MUTE (0<<13)
#define ABB_AU_SPK_MUTE_N_REG_NO_MUTE (1<<13)
#define ABB_AU_SPK_MONO_SEL_REG    (1<<14)
#define ABB_AU_SPK_MONO_SEL_REG_MASK (1<<14)
#define ABB_AU_SPK_MONO_SEL_REG_SHIFT (14)
#define ABB_AU_SPK_MONO_SEL_REG_DEFAULT (0<<14)
#define ABB_AU_SPK_MONO_SEL_REG_USE_MONO_MODE (1<<14)
#define ABB_AU_FM_SEL_REG          (1<<15)
#define ABB_AU_FM_SEL_REG_MASK     (1<<15)
#define ABB_AU_FM_SEL_REG_SHIFT    (15)
#define ABB_AU_FM_SEL_REG_DEFAULT  (0<<15)
#define ABB_AU_FM_SEL_REG_FM_OUTPUT (1<<15)

//USB_control
#define ABB_PD_USB                 (1<<0)
#define ABB_PD_USB_MASK            (1<<0)
#define ABB_PD_USB_SHIFT           (0)
#define ABB_PD_USB_POWER_UP        (0<<0)
#define ABB_PD_USB_POWER_DOWN      (1<<0)
#define ABB_USB_VREG_BIT(n)        (((n)&7)<<1)
#define ABB_USB_VREG_BIT_MASK      (7<<1)
#define ABB_USB_VREG_BIT_SHIFT     (1)
#define ABB_USB_CTRL(n)            (((n)&7)<<4)
#define ABB_USB_CTRL_MASK          (7<<4)
#define ABB_USB_CTRL_SHIFT         (4)
#define ABB_REG_SW_EN              (1<<7)
#define ABB_REG_SW_EN_MASK         (1<<7)
#define ABB_REG_SW_EN_SHIFT        (7)
#define ABB_VBIT_VUSB(n)           (((n)&7)<<8)
#define ABB_VBIT_VUSB_MASK         (7<<8)
#define ABB_VBIT_VUSB_SHIFT        (8)
#define ABB_VBIT_VUSB_2_78V        (0<<8)
#define ABB_VBIT_VUSB_2_80V        (1<<8)
#define ABB_VBIT_VUSB_2_82V        (2<<8)
#define ABB_VBIT_VUSB_2_85V        (3<<8)
#define ABB_VBIT_VUSB_2_88V        (4<<8)
#define ABB_VBIT_VUSB_2_91V        (5<<8)
#define ABB_VBIT_VUSB_2_94V        (6<<8)
#define ABB_VBIT_VUSB_2_97V        (7<<8)
#define ABB_VBIT_VA(n)             (((n)&7)<<11)
#define ABB_VBIT_VA_MASK           (7<<11)
#define ABB_VBIT_VA_SHIFT          (11)
#define ABB_RESERVED_USB(n)        (((n)&3)<<14)
#define ABB_RESERVED_USB_MASK      (3<<14)
#define ABB_RESERVED_USB_SHIFT     (14)

//GPADC_settings2
#define ABB_PD_SAR_REG             (1<<0)
#define ABB_PD_SAR_REG_MASK        (1<<0)
#define ABB_PD_SAR_REG_SHIFT       (0)
#define ABB_PD_SAR_DR              (1<<1)
#define ABB_PD_SAR_DR_MASK         (1<<1)
#define ABB_PD_SAR_DR_SHIFT        (1)
#define ABB_ADC_PD_SEL_ADC         (1<<2)
#define ABB_ADC_PD_SEL_ADC_MASK    (1<<2)
#define ABB_ADC_PD_SEL_ADC_SHIFT   (2)
#define ABB_ADC_PD_SEL_ADC_ADC_PD  (0<<2)
#define ABB_ADC_PD_SEL_ADC_MIC_PD  (1<<2)
#define ABB_HP_RCV_MUTE_ENABLE     (1<<3)
#define ABB_HP_RCV_MUTE_ENABLE_MASK (1<<3)
#define ABB_HP_RCV_MUTE_ENABLE_SHIFT (3)
#define ABB_HP_RCV_MUTE_ENABLE_NO_MUTE (0<<3)
#define ABB_HP_RCV_MUTE_ENABLE_MUTE (1<<3)
#define ABB_DELAY_BEFORE_SAMP(n)   (((n)&3)<<4)
#define ABB_DELAY_BEFORE_SAMP_MASK (3<<4)
#define ABB_DELAY_BEFORE_SAMP_SHIFT (4)
#define ABB_CONV_CLK_INV           (1<<6)
#define ABB_CONV_CLK_INV_MASK      (1<<6)
#define ABB_CONV_CLK_INV_SHIFT     (6)
#define ABB_SAMP_CLK_INV           (1<<7)
#define ABB_SAMP_CLK_INV_MASK      (1<<7)
#define ABB_SAMP_CLK_INV_SHIFT     (7)
#define ABB_SAR_ADC_MODE           (1<<8)
#define ABB_SAR_ADC_MODE_MASK      (1<<8)
#define ABB_SAR_ADC_MODE_SHIFT     (8)
#define ABB_SAR_ADC_MODE_FAST      (0<<8)
#define ABB_SAR_ADC_MODE_SLOW      (1<<8)
#define ABB_SAR_OUT_POLARITY       (1<<9)
#define ABB_SAR_OUT_POLARITY_MASK  (1<<9)
#define ABB_SAR_OUT_POLARITY_SHIFT (9)
#define ABB_GPADC_EOC_PHASE_SEL    (1<<10)
#define ABB_GPADC_EOC_PHASE_SEL_MASK (1<<10)
#define ABB_GPADC_EOC_PHASE_SEL_SHIFT (10)
#define ABB_GPADC_EOC_PHASE_SEL_HIGH (0<<10)
#define ABB_GPADC_EOC_PHASE_SEL_LOW (1<<10)
#define ABB_GPADC_START_PHASE_SEL  (1<<11)
#define ABB_GPADC_START_PHASE_SEL_MASK (1<<11)
#define ABB_GPADC_START_PHASE_SEL_SHIFT (11)
#define ABB_GPADC_START_PHASE_SEL_HIGH (0<<11)
#define ABB_GPADC_START_PHASE_SEL_LOW (1<<11)
#define ABB_TSC_SAR_SEL_R(n)       (((n)&3)<<12)
#define ABB_TSC_SAR_SEL_R_MASK     (3<<12)
#define ABB_TSC_SAR_SEL_R_SHIFT    (12)
#define ABB_SAR_VREF_BIT(n)        (((n)&3)<<14)
#define ABB_SAR_VREF_BIT_MASK      (3<<14)
#define ABB_SAR_VREF_BIT_SHIFT     (14)

//PLL_settings1
#define ABB_PLL_VREG_BIT(n)        (((n)&15)<<0)
#define ABB_PLL_VREG_BIT_MASK      (15<<0)
#define ABB_PLL_VREG_BIT_SHIFT     (0)
#define ABB_PLL_PCON(n)            (((n)&7)<<4)
#define ABB_PLL_PCON_MASK          (7<<4)
#define ABB_PLL_PCON_SHIFT         (4)
#define ABB_PLL_DIN(n)             (((n)&31)<<7)
#define ABB_PLL_DIN_MASK           (31<<7)
#define ABB_PLL_DIN_SHIFT          (7)
#define ABB_PLL_CPAUX_BIT(n)       (((n)&3)<<12)
#define ABB_PLL_CPAUX_BIT_MASK     (3<<12)
#define ABB_PLL_CPAUX_BIT_SHIFT    (12)
#define ABB_PLL_CP_BIT(n)          (((n)&3)<<14)
#define ABB_PLL_CP_BIT_MASK        (3<<14)
#define ABB_PLL_CP_BIT_SHIFT       (14)

//PLL_settings2
#define ABB_PLL_STARTUP_EN         (1<<0)
#define ABB_PLL_STARTUP_EN_MASK    (1<<0)
#define ABB_PLL_STARTUP_EN_SHIFT   (0)
#define ABB_PLL_RESET              (1<<1)
#define ABB_PLL_RESET_MASK         (1<<1)
#define ABB_PLL_RESET_SHIFT        (1)
#define ABB_SDM_CLK_SEL            (1<<2)
#define ABB_SDM_CLK_SEL_MASK       (1<<2)
#define ABB_SDM_CLK_SEL_SHIFT      (2)
#define ABB_PLL_TEST_EN            (1<<3)
#define ABB_PLL_TEST_EN_MASK       (1<<3)
#define ABB_PLL_TEST_EN_SHIFT      (3)
#define ABB_PLL_TEST_EN_DISABLE    (0<<3)
#define ABB_PLL_TEST_EN_ENABLE     (1<<3)
#define ABB_CH4_EN_REG             (1<<4)
#define ABB_CH4_EN_REG_MASK        (1<<4)
#define ABB_CH4_EN_REG_SHIFT       (4)
#define ABB_CH4_EN_REG_DISABLE     (0<<4)
#define ABB_CH4_EN_REG_ENABLE      (1<<4)
#define ABB_CH3_EN_REG             (1<<5)
#define ABB_CH3_EN_REG_MASK        (1<<5)
#define ABB_CH3_EN_REG_SHIFT       (5)
#define ABB_CH3_EN_REG_DISABLE     (0<<5)
#define ABB_CH3_EN_REG_ENABLE      (1<<5)
#define ABB_CH2_EN_REG             (1<<6)
#define ABB_CH2_EN_REG_MASK        (1<<6)
#define ABB_CH2_EN_REG_SHIFT       (6)
#define ABB_CH2_EN_REG_DISABLE     (0<<6)
#define ABB_CH2_EN_REG_ENABLE      (1<<6)
#define ABB_CH1_EN_REG             (1<<7)
#define ABB_CH1_EN_REG_MASK        (1<<7)
#define ABB_CH1_EN_REG_SHIFT       (7)
#define ABB_CH1_EN_REG_DISABLE     (0<<7)
#define ABB_CH1_EN_REG_ENABLE      (1<<7)
#define ABB_GPADC_CH_SEL_DR        (1<<8)
#define ABB_GPADC_CH_SEL_DR_MASK   (1<<8)
#define ABB_GPADC_CH_SEL_DR_SHIFT  (8)
#define ABB_GPADC_CH_SEL_DR_BY_DBB (0<<8)
#define ABB_GPADC_CH_SEL_DR_THROUGH_SPI (1<<8)
#define ABB_RESERVED_PLL(n)        (((n)&0x7F)<<9)
#define ABB_RESERVED_PLL_MASK      (0x7F<<9)
#define ABB_RESERVED_PLL_SHIFT     (9)

//FM_DAC_settings
#define ABB_VCTR_DAC_FM(n)         (((n)&3)<<0)
#define ABB_VCTR_DAC_FM_MASK       (3<<0)
#define ABB_VCTR_DAC_FM_SHIFT      (0)
#define ABB_VTEST_DAC_FM           (1<<2)
#define ABB_VTEST_DAC_FM_MASK      (1<<2)
#define ABB_VTEST_DAC_FM_SHIFT     (2)
#define ABB_PGA_TEST_EN_DAC_FM     (1<<3)
#define ABB_PGA_TEST_EN_DAC_FM_MASK (1<<3)
#define ABB_PGA_TEST_EN_DAC_FM_SHIFT (3)
#define ABB_VGAIN_DAC_FM(n)        (((n)&15)<<4)
#define ABB_VGAIN_DAC_FM_MASK      (15<<4)
#define ABB_VGAIN_DAC_FM_SHIFT     (4)
#define ABB_VBIT_ISEL_DAC_FM(n)    (((n)&15)<<8)
#define ABB_VBIT_ISEL_DAC_FM_MASK  (15<<8)
#define ABB_VBIT_ISEL_DAC_FM_SHIFT (8)
#define ABB_RESERVED_FM_DAC(n)     (((n)&15)<<12)
#define ABB_RESERVED_FM_DAC_MASK   (15<<12)
#define ABB_RESERVED_FM_DAC_SHIFT  (12)

//CODEC_LDO_settings_1
#define ABB_PD_IREF_AU_LDO_REG     (1<<0)
#define ABB_PD_IREF_AU_LDO_REG_MASK (1<<0)
#define ABB_PD_IREF_AU_LDO_REG_SHIFT (0)
#define ABB_PD_IREF_AU_LDO_DR      (1<<1)
#define ABB_PD_IREF_AU_LDO_DR_MASK (1<<1)
#define ABB_PD_IREF_AU_LDO_DR_SHIFT (1)
#define ABB_PD_AU_LDO_REG          (1<<2)
#define ABB_PD_AU_LDO_REG_MASK     (1<<2)
#define ABB_PD_AU_LDO_REG_SHIFT    (2)
#define ABB_PD_AU_LDO_DR           (1<<3)
#define ABB_PD_AU_LDO_DR_MASK      (1<<3)
#define ABB_PD_AU_LDO_DR_SHIFT     (3)
#define ABB_TEST_ENABLE_AU_LDO     (1<<4)
#define ABB_TEST_ENABLE_AU_LDO_MASK (1<<4)
#define ABB_TEST_ENABLE_AU_LDO_SHIFT (4)
#define ABB_SEL_BG_AU_LDO          (1<<5)
#define ABB_SEL_BG_AU_LDO_MASK     (1<<5)
#define ABB_SEL_BG_AU_LDO_SHIFT    (5)
#define ABB_BYPASS_AU_LDO          (1<<6)
#define ABB_BYPASS_AU_LDO_MASK     (1<<6)
#define ABB_BYPASS_AU_LDO_SHIFT    (6)
#define ABB_VBIT_AU_LDO(n)         (((n)&7)<<7)
#define ABB_VBIT_AU_LDO_MASK       (7<<7)
#define ABB_VBIT_AU_LDO_SHIFT      (7)
#define ABB_TEST_AU_LDO_BIT(n)     (((n)&7)<<10)
#define ABB_TEST_AU_LDO_BIT_MASK   (7<<10)
#define ABB_TEST_AU_LDO_BIT_SHIFT  (10)
#define ABB_RESERVED_LDO1(n)       (((n)&7)<<13)
#define ABB_RESERVED_LDO1_MASK     (7<<13)
#define ABB_RESERVED_LDO1_SHIFT    (13)

//CODEC_LDO_settings_2
#define ABB_ISEL_BIT_B(n)          (((n)&3)<<0)
#define ABB_ISEL_BIT_B_MASK        (3<<0)
#define ABB_ISEL_BIT_B_SHIFT       (0)
#define ABB_RESERVED_LD02          (1<<2)
#define ABB_RESERVED_LD02_MASK     (1<<2)
#define ABB_RESERVED_LD02_SHIFT    (2)
#define ABB_VREF_MODE(n)           (((n)&7)<<3)
#define ABB_VREF_MODE_MASK         (7<<3)
#define ABB_VREF_MODE_SHIFT        (3)
#define ABB_VCOM_BIT(n)            (((n)&0x3F)<<6)
#define ABB_VCOM_BIT_MASK          (0x3F<<6)
#define ABB_VCOM_BIT_SHIFT         (6)
#define ABB_VCOM_MODE(n)           (((n)&15)<<12)
#define ABB_VCOM_MODE_MASK         (15<<12)
#define ABB_VCOM_MODE_SHIFT        (12)

//MISC_settings
#define ABB_SYN_EN_DAC             (1<<0)
#define ABB_SYN_EN_DAC_MASK        (1<<0)
#define ABB_SYN_EN_DAC_SHIFT       (0)
#define ABB_MICBIAS_SEL            (1<<1)
#define ABB_MICBIAS_SEL_MASK       (1<<1)
#define ABB_MICBIAS_SEL_SHIFT      (1)
#define ABB_MASH_EN_ADC            (1<<2)
#define ABB_MASH_EN_ADC_MASK       (1<<2)
#define ABB_MASH_EN_ADC_SHIFT      (2)
#define ABB_TEST_EN_ADC            (1<<3)
#define ABB_TEST_EN_ADC_MASK       (1<<3)
#define ABB_TEST_EN_ADC_SHIFT      (3)
#define ABB_BOOST_BP_MIC           (1<<4)
#define ABB_BOOST_BP_MIC_MASK      (1<<4)
#define ABB_BOOST_BP_MIC_SHIFT     (4)
#define ABB_RESERVED_ANALOG(n)     (((n)&0x3F)<<5)
#define ABB_RESERVED_ANALOG_MASK   (0x3F<<5)
#define ABB_RESERVED_ANALOG_SHIFT  (5)
#define ABB_SYNC_CLK_FREQ(n)       (((n)&3)<<11)
#define ABB_SYNC_CLK_FREQ_MASK     (3<<11)
#define ABB_SYNC_CLK_FREQ_SHIFT    (11)
#define ABB_SYNC_CLK_FREQ_26M_DIV32 (0<<11)
#define ABB_SYNC_CLK_FREQ_26M_DIV24 (1<<11)
#define ABB_SYNC_CLK_FREQ_26M_DIV16 (2<<11)
#define ABB_SYNC_CLK_FREQ_26M_DIV12 (3<<11)
#define ABB_RESERVED_MISC(n)       (((n)&7)<<13)
#define ABB_RESERVED_MISC_MASK     (7<<13)
#define ABB_RESERVED_MISC_SHIFT    (13)

//CODEC_mode_sel
#define ABB_PA_EN_R_SPK_REG        (1<<0)
#define ABB_PA_EN_R_SPK_REG_MASK   (1<<0)
#define ABB_PA_EN_R_SPK_REG_SHIFT  (0)
#define ABB_PA_EN_L_SPK_REG        (1<<1)
#define ABB_PA_EN_L_SPK_REG_MASK   (1<<1)
#define ABB_PA_EN_L_SPK_REG_SHIFT  (1)
#define ABB_PA_EN_HP_REG           (1<<2)
#define ABB_PA_EN_HP_REG_MASK      (1<<2)
#define ABB_PA_EN_HP_REG_SHIFT     (2)
#define ABB_PA_EN_RECI_REG         (1<<3)
#define ABB_PA_EN_RECI_REG_MASK    (1<<3)
#define ABB_PA_EN_RECI_REG_SHIFT   (3)
#define ABB_HP_FM_MODE_REG         (1<<4)
#define ABB_HP_FM_MODE_REG_MASK    (1<<4)
#define ABB_HP_FM_MODE_REG_SHIFT   (4)
#define ABB_HP_DAC_MODE_REG        (1<<5)
#define ABB_HP_DAC_MODE_REG_MASK   (1<<5)
#define ABB_HP_DAC_MODE_REG_SHIFT  (5)
#define ABB_HP_MODE2_R_REG         (1<<6)
#define ABB_HP_MODE2_R_REG_MASK    (1<<6)
#define ABB_HP_MODE2_R_REG_SHIFT   (6)
#define ABB_HP_MODE2_L_REG         (1<<7)
#define ABB_HP_MODE2_L_REG_MASK    (1<<7)
#define ABB_HP_MODE2_L_REG_SHIFT   (7)
#define ABB_HP_MODE1_R_REG         (1<<8)
#define ABB_HP_MODE1_R_REG_MASK    (1<<8)
#define ABB_HP_MODE1_R_REG_SHIFT   (8)
#define ABB_HP_MODE1_L_REG         (1<<9)
#define ABB_HP_MODE1_L_REG_MASK    (1<<9)
#define ABB_HP_MODE1_L_REG_SHIFT   (9)
#define ABB_SPK_FM_MODE_REG        (1<<10)
#define ABB_SPK_FM_MODE_REG_MASK   (1<<10)
#define ABB_SPK_FM_MODE_REG_SHIFT  (10)
#define ABB_SPK_MODE2_R_REG        (1<<11)
#define ABB_SPK_MODE2_R_REG_MASK   (1<<11)
#define ABB_SPK_MODE2_R_REG_SHIFT  (11)
#define ABB_SPK_MODE2_L_REG        (1<<12)
#define ABB_SPK_MODE2_L_REG_MASK   (1<<12)
#define ABB_SPK_MODE2_L_REG_SHIFT  (12)
#define ABB_SPK_MODE1_R_REG        (1<<13)
#define ABB_SPK_MODE1_R_REG_MASK   (1<<13)
#define ABB_SPK_MODE1_R_REG_SHIFT  (13)
#define ABB_SPK_MODE1_L_REG        (1<<14)
#define ABB_SPK_MODE1_L_REG_MASK   (1<<14)
#define ABB_SPK_MODE1_L_REG_SHIFT  (14)
#define ABB_MUX_MODE_DR            (1<<15)
#define ABB_MUX_MODE_DR_MASK       (1<<15)
#define ABB_MUX_MODE_DR_SHIFT      (15)
#define ABB_MUX_MODE_DR_AUTO       (0<<15)
#define ABB_MUX_MODE_DR_THROUGH_SPI (1<<15)

//CODEC_calib_settings
#define ABB_CAL_BIT_REG(n)         (((n)&7)<<0)
#define ABB_CAL_BIT_REG_MASK       (7<<0)
#define ABB_CAL_BIT_REG_SHIFT      (0)
#define ABB_CAL_BIT_DR             (1<<3)
#define ABB_CAL_BIT_DR_MASK        (1<<3)
#define ABB_CAL_BIT_DR_SHIFT       (3)
#define ABB_CAL_CLK_INV            (1<<4)
#define ABB_CAL_CLK_INV_MASK       (1<<4)
#define ABB_CAL_CLK_INV_SHIFT      (4)
#define ABB_CAL_OUT_POLARTIY       (1<<5)
#define ABB_CAL_OUT_POLARTIY_MASK  (1<<5)
#define ABB_CAL_OUT_POLARTIY_SHIFT (5)
#define ABB_RESETN_CAL_REG         (1<<6)
#define ABB_RESETN_CAL_REG_MASK    (1<<6)
#define ABB_RESETN_CAL_REG_SHIFT   (6)
#define ABB_RESETN_CAL_DR          (1<<7)
#define ABB_RESETN_CAL_DR_MASK     (1<<7)
#define ABB_RESETN_CAL_DR_SHIFT    (7)
#define ABB_CAL_BYPASS             (1<<8)
#define ABB_CAL_BYPASS_MASK        (1<<8)
#define ABB_CAL_BYPASS_SHIFT       (8)
#define ABB_CAL_BYPASS_DO          (0<<8)
#define ABB_CAL_BYPASS_BYPASS      (1<<8)
#define ABB_TEST_EN_SPK            (1<<9)
#define ABB_TEST_EN_SPK_MASK       (1<<9)
#define ABB_TEST_EN_SPK_SHIFT      (9)
#define ABB_SPK_LINEIN_MODE        (1<<10)
#define ABB_SPK_LINEIN_MODE_MASK   (1<<10)
#define ABB_SPK_LINEIN_MODE_SHIFT  (10)
#define ABB_HP_LINEIN_MODE         (1<<11)
#define ABB_HP_LINEIN_MODE_MASK    (1<<11)
#define ABB_HP_LINEIN_MODE_SHIFT   (11)
#define ABB_RESERVED_CALIB(n)      (((n)&15)<<12)
#define ABB_RESERVED_CALIB_MASK    (15<<12)
#define ABB_RESERVED_CALIB_SHIFT   (12)

//Power_control
#define ABB_DAC_EN_CODEC_REG       (1<<0)
#define ABB_DAC_EN_CODEC_REG_MASK  (1<<0)
#define ABB_DAC_EN_CODEC_REG_SHIFT (0)
#define ABB_DAC_EN_CODEC_DR        (1<<1)
#define ABB_DAC_EN_CODEC_DR_MASK   (1<<1)
#define ABB_DAC_EN_CODEC_DR_SHIFT  (1)
#define ABB_ADC_EN_CODEC_REG       (1<<2)
#define ABB_ADC_EN_CODEC_REG_MASK  (1<<2)
#define ABB_ADC_EN_CODEC_REG_SHIFT (2)
#define ABB_ADC_EN_CODEC_DR        (1<<3)
#define ABB_ADC_EN_CODEC_DR_MASK   (1<<3)
#define ABB_ADC_EN_CODEC_DR_SHIFT  (3)
#define ABB_RSTN_CODEC_REG         (1<<4)
#define ABB_RSTN_CODEC_REG_MASK    (1<<4)
#define ABB_RSTN_CODEC_REG_SHIFT   (4)
#define ABB_RSTN_CODEC_DR          (1<<5)
#define ABB_RSTN_CODEC_DR_MASK     (1<<5)
#define ABB_RSTN_CODEC_DR_SHIFT    (5)
#define ABB_RESERVED_POWER(n)      (((n)&3)<<6)
#define ABB_RESERVED_POWER_MASK    (3<<6)
#define ABB_RESERVED_POWER_SHIFT   (6)
#define ABB_PD_DAC_FM_REG          (1<<8)
#define ABB_PD_DAC_FM_REG_MASK     (1<<8)
#define ABB_PD_DAC_FM_REG_SHIFT    (8)
#define ABB_PD_DAC_FM_DR           (1<<9)
#define ABB_PD_DAC_FM_DR_MASK      (1<<9)
#define ABB_PD_DAC_FM_DR_SHIFT     (9)
#define ABB_PD_DAC_FM_DR_AUTO      (0<<9)
#define ABB_PD_DAC_FM_DR_THROUGH_SPI (1<<9)
#define ABB_PD_DAC_R_REG           (1<<10)
#define ABB_PD_DAC_R_REG_MASK      (1<<10)
#define ABB_PD_DAC_R_REG_SHIFT     (10)
#define ABB_PD_DAC_L_REG           (1<<11)
#define ABB_PD_DAC_L_REG_MASK      (1<<11)
#define ABB_PD_DAC_L_REG_SHIFT     (11)
#define ABB_PD_MICBIAS_REG         (1<<12)
#define ABB_PD_MICBIAS_REG_MASK    (1<<12)
#define ABB_PD_MICBIAS_REG_SHIFT   (12)
#define ABB_PD_ADC_REG             (1<<13)
#define ABB_PD_ADC_REG_MASK        (1<<13)
#define ABB_PD_ADC_REG_SHIFT       (13)
#define ABB_PD_ALL_BIAS_REG        (1<<14)
#define ABB_PD_ALL_BIAS_REG_MASK   (1<<14)
#define ABB_PD_ALL_BIAS_REG_SHIFT  (14)
#define ABB_PD_CODEC_DR            (1<<15)
#define ABB_PD_CODEC_DR_MASK       (1<<15)
#define ABB_PD_CODEC_DR_SHIFT      (15)
#define ABB_PD_CODEC_DR_AUTO       (0<<15)
#define ABB_PD_CODEC_DR_THROUGH_SPI (1<<15)

//CODEC_reset_control
#define ABB_SPI_OUT_SEL            (1<<0)
#define ABB_SPI_OUT_SEL_MASK       (1<<0)
#define ABB_SPI_OUT_SEL_SHIFT      (0)
#define ABB_SPI_OUT_SEL_FROM_ABB   (0<<0)
#define ABB_SPI_OUT_SEL_FROM_CODEC (1<<0)
#define ABB_RESERVED_RESET(n)      (((n)&0x7F)<<1)
#define ABB_RESERVED_RESET_MASK    (0x7F<<1)
#define ABB_RESERVED_RESET_SHIFT   (1)
#define ABB_RESET_PA_SPK_REG       (1<<8)
#define ABB_RESET_PA_SPK_REG_MASK  (1<<8)
#define ABB_RESET_PA_SPK_REG_SHIFT (8)
#define ABB_RESET_PA_HP_REG        (1<<9)
#define ABB_RESET_PA_HP_REG_MASK   (1<<9)
#define ABB_RESET_PA_HP_REG_SHIFT  (9)
#define ABB_RESET_PA_RECI_REG      (1<<10)
#define ABB_RESET_PA_RECI_REG_MASK (1<<10)
#define ABB_RESET_PA_RECI_REG_SHIFT (10)
#define ABB_RESET_MUX_D2S_REG      (1<<11)
#define ABB_RESET_MUX_D2S_REG_MASK (1<<11)
#define ABB_RESET_MUX_D2S_REG_SHIFT (11)
#define ABB_RESET_MUX_D2D_REG      (1<<12)
#define ABB_RESET_MUX_D2D_REG_MASK (1<<12)
#define ABB_RESET_MUX_D2D_REG_SHIFT (12)
#define ABB_RESET_EN_ADC_REG       (1<<13)
#define ABB_RESET_EN_ADC_REG_MASK  (1<<13)
#define ABB_RESET_EN_ADC_REG_SHIFT (13)
#define ABB_RESET_MIC_REG          (1<<14)
#define ABB_RESET_MIC_REG_MASK     (1<<14)
#define ABB_RESET_MIC_REG_SHIFT    (14)
#define ABB_RESET_CODEC_DR         (1<<15)
#define ABB_RESET_CODEC_DR_MASK    (1<<15)
#define ABB_RESET_CODEC_DR_SHIFT   (15)





#endif

